
<script type="text/javascript">
		var node = document.getElementById("b2");
		document.write("<hr/>");
		document.write(node.innerText);
		document.write("<hr/>");
		document.write(node.innerHTML);
</script>
<?php
	define ("MAX_SIZE","4096");
	function getExtension($str)
	{
		 $i = strrpos($str,".");
		 if (!$i) { return ""; }
		 $l = strlen($str) - $i;
		 $ext = substr($str,$i+1,$l);
		 return $ext;
	}
?>   

<?php
	include_once('components/sukien/xuly.php');
	include_once('components/sukien/class_sukien.php');
	if(!isset($_SESSION["Username"]))
	{	
        header("Location:index.php?com=user&fun=login&user=&pass=&remember=&Error=0&mess=0");
	}
	
	$Loi = "";
	$tensukien = "mac dinh";
	$noidung = "mac dinh";
	$ngaybatdau = '2010-1-1';
	$ngayketthuc = '2010-1-1';
	$e = new class_sukien();
	
	if (isset($_SESSION['Username']))
	{
		$user = $_SESSION['Username'];
		if(isset($_POST['TenSuKien']))
		{
			$Loi = "Chưa nhập ten su kien";
		}
		else
		{
			//save pdf
			if(isset($_POST['TenSuKien']))
			$tensukien = $_POST['TenSuKien'];
			if(isset($_POST['editor1']))
			$noidung = $_POST['editor1'];
			if(isset($_POST['NgayBatDau']))
			$ngaybatdau = $_POST['NgayBatDau'];
			if(isset($_POST['NgayKetThuc']))
			$ngayketthuc = $_POST['NgayKetThuc'];
					
			$kq = $e->ThemSuKien($tensukien,$user,$noidung,$ngaybatdau,$ngayketthuc);
			if($kq){
				$Loi = "Thêm thành công!";
			}	
			if(@file_get_contents($filename))
				$Loi = "Vui lòng đặt tựa su kien khác";
			else
			{
				$data = "";
				if(isset( $_POST ))
					$postArray = &$_POST ;			// 4.1.0 or later, use $_POST
				else
					$postArray = &$HTTP_POST_VARS ;	// prior to 4.1.0, use HTTP_POST_VARS
		
				foreach ($postArray as $sForm => $value )
				{
					/*
					if ( get_magic_quotes_gpc() )
						$postedValue = htmlspecialchars( stripslashes( $value ) ) ;
					else
						$postedValue = htmlspecialchars( $value ) ;
						*/
						$data=$data.$value;
				}
				
				require('library/fpdf/fpdf.php');
				$dir='';
							
				$pdf=new FPDF('P','mm','A4');
				$pdf->SetMargins(25.0,20.0,20.0);
				$pdf=new FPDF();
				$pdf->AddPage();
				$pdf->SetFont('times','',10);
				//$pdf->SetFont("arialuni","","10");
				$pdf->Cell(0,12,$data,0,1,'C');

				//$pdf->Output($filename,$dir);
				
				
				/*
				require('library/tfpdf/tfpdf.php');
				$pdf = new tFPDF();
				$pdf->AddPage();
				
				// Add a Unicode font (uses UTF-8)
				$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true);
				$pdf->SetFont('DejaVu','',14);
	
				// Select a standard font (uses windows-1252)
				$pdf->SetFont('Arial','',14);
				$pdf->Ln(10);
				$pdf->Write(5,'The file size of this PDF is only 17 KB.');
				//$pdf->Write(5,$data);
				$pdf->Output();
				*/
			}	
		}
	}

?>
<form method="post">
<div style='color:red' align='left'> <?php echo $Loi ?></div>
<table id="sample">
<tr>
	<td>Tên sự kiện</td>
    <td><input name="TenSuKien" type="text" id="TenSuKien" size="60"  value=""/></td>
</tr>
<tr>
	<td>Ngày bắt đầu</td>
    <td><input name="NgayBatDau" type="text" id="NgayBatDau" size="60"  value=""/></td>
</tr>
<tr>
	<td>Ngày kết thúc</td>
    <td><input name="NgayKetThuc" type="text" id="NgayKetThuc" size="60"  value=""/></td>
</tr>
<tr>
	<td>Hình ảnh</td>
    <td><input type="file" id="hinhanh" name="hinhanh" /></td>
</tr>
<tr>
	<td>Nội dung</td>
    <td>&nbsp;</td>
</tr>
<tr>
<td colspan="2">
    <div id="alerts"></div>
        <p>
            <label for="editor1"></label><br />
            <textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="10">Chi tiết sự kiện ở đây !!!</textarea>
        </p>
        <p>
            <input type="submit" id="ThemSK" name="ThemSK" value="Thêm"/>
        </p>
</td>
</tr>
</table>
<form>